import java.util.Scanner;

public class DES {
    public static int ls , lc;
    public static Scanner scan = new Scanner(System.in);
    protected static char[] ipTable = {
            58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4,
            62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8,
            57, 49, 41, 33, 25, 17,  9, 1, 59, 51, 43, 35, 27, 19, 11, 3,
            61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7
    };

    protected static char[] keyInit = {
            57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18,
            10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36,
            63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22,
            14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4
    };

    protected static char[] keyCompress = {
            14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10,
            23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2,
            41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48,
            44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32
    };

    public static void main(String[] args)
    {
        System.out.println(1^0);
        System.out.println(0^1);
        System.out.println(0^0);
        System.out.println(1^1);

        System.out.println((char)('q'^'B'));

        //standerd(scan.next());
        //左移1位
        System.out.println((char)(0b11010001)1);
//        Code key = new Code();


    }

//1234567812345678123456781234567812345678123456781234567812345678


//    //将明文进行des加密
//    public static String desEncrypt(String plaintext,String str)
//    {
//        String ciphertext="";
//        char[][] arr = standerd(plaintext);
//        char[] key = getKey(standerd(str)[0]);
//
//        for(int i=0; i<arr.length; i++){
//            ciphertext += encrypt(arr[i], key);
//        }
//        return ciphertext;
//    }

    //将64位字符进行des加密
    public static String encrypt(char[] plaintext, char[] str)
    {
        String ciphertext="";
        //进行ip置换
        plaintext = ip(plaintext);
        char[] l0 = new char[32];
        char[] r0 = new char[32];
        for(int i=0; i<32; i++){
            l0[i] = plaintext[i];
            r0[i] = plaintext[i+32];
        }

        return ciphertext;
    }

    //返回划分为64位的字符数组
    public static char[][] standerd(String str)
    {
        char[][] arr = new char[str.length()/64+1][];
        //不足64位补0
        if(str.length()<=64){
            for(int i=0; i<=64-str.length(); i++){
                str += '0';
            }
            arr[0] = str.toCharArray();
            return arr;
        }
        //多于64，分成多个数组，不够补零
        if(str.length()>64){
            int i=0;
            while(str.length()>64){
                arr[i] = str.substring(0,64).toCharArray();
                str = str.substring(64);
                i++;
            }
            arr[i] = standerd(str)[0];
            return arr;
        }
        return arr;
    }

    //IP置换
    public static char[] ip(char[] bit64)
    {
        char[] arr = new char[0];
        for(int i=0; i<64; i++)
        {
            arr[i] = bit64[ipTable[i]-1];
        }
        return arr;
    }

    //逆IP置换
    public static char[] inIp(char[] bit64)
    {
        char[] arr = new char[0];
        for(int i=0; i<64; i++)
        {
            arr[ipTable[i]-1] = bit64[i];
        }
        return arr;
    }

    //返回56位密钥
    public static char[] getFirstKey(char[] key){
        char[] key56 = new char[56];
        int k=0;
        for(int i=0; i<56; i++){
            key56[i] = key[ipTable[i]-1];
        }
        return key56;
    }

//    //返回各轮密钥
//    public static char[] getKey(char[] keyL, char[] keyR, int round){
//
//    }

    //左移操作
    public static char[] toLf(char[] key, int digit){
        for(int i=0; i<key.length; i++){
            key[i] = (char) ((char)key[i]<<digit);
        }
        return key;
    }

//    //返回48位压缩密钥
//    public static char[] getKey48(char[] key){
//
//    }


    //
    public static char[] toHalf(char[] bit64 , int start)
    {
        char[] half = new char[32];
        for(int i=start; i<start+32; i++){
            half[i%32] = bit64[i];
        }
        return half;
    }









//转成ASCII码
//    public static char[][] toPart(String str) {
//        ls = str.length()/8;
//        if(str.length()%8 != 0)
//            ls++;
//        char[][] arr = new char[ls][64];
//        char[] binArr = new char[64];
//        int start=0;
//        for(int i=0; i<ls; i++) {
//            char[] temp = str.substring(start,start+8).toCharArray();
//            start += 8;
//            for(int j=0; j<8; j++) {
//                String bin = Integer.toBinaryString(temp[j]);
//                if(bin.length()!=8){
//                    while(bin.length() != 8)
//                        bin = "0" + bin;
//                }
//                for(int k=j*8; k<j*8+8; k++)
//                    binArr[k] = bin.toCharArray()[k%8];
//            }
//            for(int b=0; b<64; b++){
//                arr[i][b] = binArr[b];
//            }
//        }
//        return arr;
//    }

}